/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tecbooks;

import javax.swing.JDialog;

/**
 *
 * @author Diôgo'Tenório
 */
public class BuscaCliente extends javax.swing.JFrame {

    /**
     * Creates new form BuscaCliente
     */
    public BuscaCliente() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        dialogMaisInfo = new javax.swing.JDialog();
        paneInfo2 = new javax.swing.JPanel();
        lblClienteEstado = new javax.swing.JLabel();
        lblClienteBairro = new javax.swing.JLabel();
        lblClienteRua = new javax.swing.JLabel();
        lblClienteNome7 = new javax.swing.JLabel();
        lblClienteCidade = new javax.swing.JLabel();
        lblClienteBairro1 = new javax.swing.JLabel();
        btnJdialog = new javax.swing.JButton();
        lblId = new javax.swing.JLabel();
        lblAviso = new javax.swing.JLabel();
        txtId = new javax.swing.JTextField();
        tbnBuscar = new javax.swing.JButton();
        btnSair = new javax.swing.JButton();
        btnMaisInformacoes = new javax.swing.JButton();
        paneInfo1 = new javax.swing.JPanel();
        lblClienteNome = new javax.swing.JLabel();
        lblClienteNome1 = new javax.swing.JLabel();
        lblClienteNome2 = new javax.swing.JLabel();
        lblClienteNome3 = new javax.swing.JLabel();

        dialogMaisInfo.setTitle("Mains Informaçoes");
        dialogMaisInfo.setBackground(java.awt.Color.white);
        dialogMaisInfo.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        dialogMaisInfo.setMinimumSize(new java.awt.Dimension(334, 225));
        dialogMaisInfo.setResizable(false);
        dialogMaisInfo.setType(java.awt.Window.Type.POPUP);

        paneInfo2.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED, new java.awt.Color(0, 0, 0), new java.awt.Color(255, 51, 0), new java.awt.Color(204, 51, 0), new java.awt.Color(0, 0, 0)), "Dados do Cliente"));

        lblClienteEstado.setText("Estado: Alagoas");

        lblClienteBairro.setText("Bairro: Centro");

        lblClienteRua.setText("Rua: Avenida Beija-Flor        N° 101");

        lblClienteNome7.setText("Id:");

        lblClienteCidade.setText("Cidade: Arapiraca");

        lblClienteBairro1.setText("Cep: 123-7890");

        javax.swing.GroupLayout paneInfo2Layout = new javax.swing.GroupLayout(paneInfo2);
        paneInfo2.setLayout(paneInfo2Layout);
        paneInfo2Layout.setHorizontalGroup(
            paneInfo2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(paneInfo2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(paneInfo2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblClienteRua, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(paneInfo2Layout.createSequentialGroup()
                        .addGroup(paneInfo2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(lblClienteBairro, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(lblClienteNome7, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblClienteEstado, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 116, Short.MAX_VALUE))
                        .addGap(18, 18, 18)
                        .addGroup(paneInfo2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(paneInfo2Layout.createSequentialGroup()
                                .addComponent(lblClienteCidade, javax.swing.GroupLayout.DEFAULT_SIZE, 116, Short.MAX_VALUE)
                                .addGap(29, 29, 29))
                            .addComponent(lblClienteBairro1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                .addContainerGap())
        );
        paneInfo2Layout.setVerticalGroup(
            paneInfo2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(paneInfo2Layout.createSequentialGroup()
                .addGap(5, 5, 5)
                .addComponent(lblClienteNome7)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(paneInfo2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblClienteEstado)
                    .addComponent(lblClienteCidade))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(paneInfo2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblClienteBairro)
                    .addComponent(lblClienteBairro1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lblClienteRua)
                .addContainerGap(38, Short.MAX_VALUE))
        );

        btnJdialog.setText("OK");
        btnJdialog.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnJdialogActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout dialogMaisInfoLayout = new javax.swing.GroupLayout(dialogMaisInfo.getContentPane());
        dialogMaisInfo.getContentPane().setLayout(dialogMaisInfoLayout);
        dialogMaisInfoLayout.setHorizontalGroup(
            dialogMaisInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, dialogMaisInfoLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(paneInfo2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(dialogMaisInfoLayout.createSequentialGroup()
                .addGap(131, 131, 131)
                .addComponent(btnJdialog)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        dialogMaisInfoLayout.setVerticalGroup(
            dialogMaisInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dialogMaisInfoLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(paneInfo2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnJdialog)
                .addContainerGap(15, Short.MAX_VALUE))
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Busca Cliente");
        setMinimumSize(new java.awt.Dimension(293, 276));
        setPreferredSize(new java.awt.Dimension(293, 300));
        setResizable(false);

        lblId.setText("Id:");

        lblAviso.setForeground(new java.awt.Color(255, 0, 0));

        txtId.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                apenasNumeros(evt);
            }
        });

        tbnBuscar.setText("Buscar");
        tbnBuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tbnBuscarActionPerformed(evt);
            }
        });

        btnSair.setText("Sair");
        btnSair.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSairActionPerformed(evt);
            }
        });

        btnMaisInformacoes.setText("Mais informações");
        btnMaisInformacoes.setVisible(false);
        btnMaisInformacoes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnMaisInformacoesActionPerformed(evt);
            }
        });

        paneInfo1.setVisible(false);
        paneInfo1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED, new java.awt.Color(0, 0, 0), new java.awt.Color(255, 51, 0), new java.awt.Color(204, 51, 0), new java.awt.Color(0, 0, 0)), "Dados do Cliente"));

        lblClienteNome.setText("Nome: João Pedro Luiz Santos");

        lblClienteNome1.setText("Telefone: (82) 1234-4321");

        lblClienteNome2.setText("E-mail: pedroluiz@gmail.com");

        lblClienteNome3.setText("Id:");

        javax.swing.GroupLayout paneInfo1Layout = new javax.swing.GroupLayout(paneInfo1);
        paneInfo1.setLayout(paneInfo1Layout);
        paneInfo1Layout.setHorizontalGroup(
            paneInfo1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(paneInfo1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(paneInfo1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblClienteNome, javax.swing.GroupLayout.DEFAULT_SIZE, 241, Short.MAX_VALUE)
                    .addGroup(paneInfo1Layout.createSequentialGroup()
                        .addComponent(lblClienteNome3, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addComponent(lblClienteNome1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(lblClienteNome2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        paneInfo1Layout.setVerticalGroup(
            paneInfo1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(paneInfo1Layout.createSequentialGroup()
                .addGap(17, 17, 17)
                .addComponent(lblClienteNome3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lblClienteNome)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lblClienteNome1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lblClienteNome2)
                .addContainerGap(20, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(paneInfo1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(lblId)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblAviso, javax.swing.GroupLayout.PREFERRED_SIZE, 202, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(txtId, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(tbnBuscar)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(btnSair)))
                        .addGap(0, 46, Short.MAX_VALUE)))
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(0, 0, Short.MAX_VALUE)
                .addComponent(btnMaisInformacoes)
                .addGap(86, 86, 86))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblId)
                    .addComponent(txtId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tbnBuscar)
                    .addComponent(btnSair))
                .addGap(2, 2, 2)
                .addComponent(lblAviso, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(paneInfo1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(26, 26, 26)
                .addComponent(btnMaisInformacoes)
                .addContainerGap(33, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnSairActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSairActionPerformed
        // TODO add your handling code here:
        dispose();
        new TelaPrincipal().setVisible(true);
    }//GEN-LAST:event_btnSairActionPerformed

    private void btnMaisInformacoesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMaisInformacoesActionPerformed
        // TODO add your handling code here:
        dialogMaisInfo.setVisible(true);
    }//GEN-LAST:event_btnMaisInformacoesActionPerformed

    private void apenasNumeros(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_apenasNumeros
        // TODO add your handling code here:
           String numeros = "0123456789";
        if(!numeros.contains(evt.getKeyChar()+"") && (int)evt.getKeyChar() != 8){
            evt.consume();
            lblAviso.setText("Por favor, informe apenas números!");
        }
        else{
           lblAviso.setText("");
        }
    }//GEN-LAST:event_apenasNumeros

    private void tbnBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tbnBuscarActionPerformed
        // TODO add your handling code here:
        //trata txtId
        if ( txtId.getText().equals("1234")){
            paneInfo1.setVisible(true);
            btnMaisInformacoes.setVisible(true);
        }
        else{
            lblAviso.setText("Cliente não cadastrado!");
        }
    }//GEN-LAST:event_tbnBuscarActionPerformed

    private void btnJdialogActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnJdialogActionPerformed
        // TODO add your handling code here:
        dialogMaisInfo.dispose();
    }//GEN-LAST:event_btnJdialogActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(BuscaCliente.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(BuscaCliente.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(BuscaCliente.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(BuscaCliente.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new BuscaCliente().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnJdialog;
    private javax.swing.JButton btnMaisInformacoes;
    private javax.swing.JButton btnSair;
    private javax.swing.JDialog dialogMaisInfo;
    private javax.swing.JLabel lblAviso;
    private javax.swing.JLabel lblClienteBairro;
    private javax.swing.JLabel lblClienteBairro1;
    private javax.swing.JLabel lblClienteCidade;
    private javax.swing.JLabel lblClienteEstado;
    private javax.swing.JLabel lblClienteNome;
    private javax.swing.JLabel lblClienteNome1;
    private javax.swing.JLabel lblClienteNome2;
    private javax.swing.JLabel lblClienteNome3;
    private javax.swing.JLabel lblClienteNome7;
    private javax.swing.JLabel lblClienteRua;
    private javax.swing.JLabel lblId;
    private javax.swing.JPanel paneInfo1;
    private javax.swing.JPanel paneInfo2;
    private javax.swing.JButton tbnBuscar;
    private javax.swing.JTextField txtId;
    // End of variables declaration//GEN-END:variables
}
